package com.suxin.socket.yinfei.pusher;

import com.alibaba.fastjson.JSONObject;
import com.suxin.socket.yinfei.session.SessionConnectionHolder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Tang
 * @classname AbstractPusherHandler
 * @description [ AbstractPusherHandler ]
 * @date 2021/8/19 21:27
 */
@Slf4j
public abstract class AbstractPusherHandler<T> implements PusherHandler<T> {

    @Getter
    protected SessionConnectionHolder sessionConnectionHolder;
    protected DefaultPusherHandler proxyPusherHandler;

    public AbstractPusherHandler(SessionConnectionHolder sessionConnectionHolder) {
        this.sessionConnectionHolder = sessionConnectionHolder;
        this.proxyPusherHandler = new DefaultPusherHandler(sessionConnectionHolder);
    }

    @Override
    public void push(T msg, String identifier) {
        log.info("要发送的数据为:{}", JSONObject.toJSONString(msg));
        proxyPusherHandler.push(msg, identifier);
    }
}